const app = getApp()
import { API_BASE } from '../../utils/api'


Page({
  data: {
    navigation: [],
    advertPic: [],
    article: [],
    url:`../articles/articles?id={{item.id}}&navigationText={{item.navigationText}}`,
    artuckeUrl:'../articlels/articlels?id={{typeList.lId}}&navigationText={{typeList.navigationText}}'
  },
  toSearch: function () {
    wx.navigateTo({
      url: '/pages/search/search',
    })
  },
  onPullDownRefresh() {
    // console.log('下拉了');
    wx.showLoading({
      title: '玩命加载中',
    })
    wx.request({
      url: API_BASE,
      success: (res) => {
        wx.hideLoading();
        // console.log('下拉结束')
        wx.stopPullDownRefresh()
      }
    })
  },

  onLoad: function () {
    wx.showLoading({
      title: '玩命加载中',
    })
    self = this
    wx.request({
      url: API_BASE,
      data: {},
      method: 'GET', 
      success: function (res) {
        // console.log(res)
        self.setData({
          advertPic: res.data.data.advertPic,
          navigation: res.data.data.navigation,
          article: res.data.data.article
        })
        wx.hideLoading();
      },
      fail: function () {
        wx.showModal({
          title: '提示',
          content: 您的网络状态不佳,
          showCancel: false
        })
      }
    })
  }
})